/**
 * Created by 黄忠园 on 2017/12/25.
 */
angular.module('service.job.jobCommunication', [
        'ngResource',
        'ngCookies'
    ])
    .service('JobJobCommunicationService', JobJobCommunicationService);
JobJobCommunicationService.$inject = ['$resource'];
function JobJobCommunicationService($resource) {

    // 新增沟通（评价）记录(ps 可以只传recordid，type，personalid和content)
    this.addCom = function (info, success, error) {
        var resource = $resource(joburl + "/jobCommunication ");
        return resource.save({}, info, success, error);
    };

    // 根据jobId查询沟通（评价）记录
    this.getEvaluate = function (jobId, success, error) {
        var resource = $resource(joburl + "/jobCommunication/:jobId", {}, {
            query: {
                method: 'GET',
                isArray: true,
                transformResponse: function (data, headers) {
                    data = JSON.parse(data);
                    for (var index in data) {
                        data[index].content = JSON.parse(data[index].content)
                    }
                    return data;
                }
            }
        });
        return resource.query({jobId: jobId}, success, error);
    }
}